#!/bin/bash

#The sim file represents the file generated description file
SIM_FILE="proc.Raw"

rm proc/* 

if [ -f tmp/sim.jpg ]
then
        rm tmp/sim.jpg
fi

#Compile source of simulator
javac -d bin src/edu/vcu/csl/ess/*.java src/xml/*.java
#Run parser and code generator
#usage: java ESSXMLParser <filename> <model_type>
java -cp bin xml.ESSXMLParser $1 99

#Comment in (8 lines) for Java version
javac -g:none -O proc/*.java

if [ "$2" == 'DEBUG' ]
then
        time java $SIM_FILE
else
        java $SIM_FILE
fi

#Comment in (5 lines) for C version
#cd proc
#echo -e "Compiling...\n"
#time gcc -O3 -lm Raw.c
#echo -e "Running...\n"
#time ./a.out

#Comment in (7 lines) for R post-processing
if [ "$2" == 'DEBUG' ]
then
        cd scripts
        ./pic ../proc/Raw.csv ../tmp/sim.jpg
        eog ../tmp/sim.jpg
        cd ..
fi

